import * as echarts from "echarts";
import { onUnmounted } from "vue";
import { onMounted } from "vue";
import { ref } from "vue";

export default function useEchart(divEl) {
    const echartInstance = echarts.init(divEl, null, { renderer: "svg" });

    onUnmounted(() => {
        echartInstance.dispose()  // 释放资源
    })
    function setOption(option) {
        echartInstance.setOption(option)
    }
    function resizeEchart() {
        echartInstance.resize()
    }

    return {
        echartInstance,
        setOption,
        resizeEchart
    }
}